package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1014 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maxScoreSightseeingPair(int[] values) {
            int ans = 0, preAns = 0;
            for (int i = 1; i < values.length; i++) {
                preAns = Math.max(preAns - 1 + values[i] - values[i - 1], values[i] + values[i - 1] - 1);
                ans = Math.max(ans, preAns);
            }

            return ans;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.maxScoreSightseeingPair(InputUtil.toIntegerArray("[8,1,5,2,6]")));
        System.out.println(solution.maxScoreSightseeingPair(InputUtil.toIntegerArray("[1,2]")));
    }

    public static void main(String[] args) throws Exception {
        LC1014 an = new LC1014();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
